package com.itlong.cloud.operate.service.impl;

import com.itlong.cloud.POJO.PO.PersonPO;
import com.itlong.cloud.PlatformConstants;
import com.itlong.cloud.operate.dao.IOperatePersonDao;
import com.itlong.cloud.operate.service.IOperatePersonService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <desc>
 *      XXXXXXXXX实现类。
 * </desc>
 *
 * @createDate 2017/08/29
 */
@Service
public class OperatePersonServiceImpl implements IOperatePersonService {

    private static final Logger LOG = LoggerFactory.getLogger(OperatePersonServiceImpl.class);

    @Autowired
    private IOperatePersonDao iOperatePersonDao;


   /**
     * <desc>
     *      DEMO示例。
     * <desc/>
     *
     * @param id 主键
     * @return hello
     * @author Wenchao.L
     * @createDate 2017/08/29
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public PersonPO getPersonById(Integer id) {
        PersonPO  p = new PersonPO(id,null);
        return iOperatePersonDao.getOne(p);
    }

    /**
     * <desc>
     *      DEMO示例。
     * <desc/>
     *
     * @param personPO xxxxxx
     * @return hello
     * @author Wenchao.L
     * @createDate 2017/08/29
     */
    @Transactional(rollbackFor = Exception.class)
    public void insertPerson(PersonPO personPO) {
        try {
            int result = iOperatePersonDao.save(SqlUtil.durableData(personPO, PlatformConstants.TABLE_SAVE));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
